package com.igeek.boot.controller;

import com.igeek.boot.entity.Items;
import com.igeek.boot.service.ItemsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Author fengqq
 * @Description TODO
 * @Date 2024/9/9  9:54
 */
@RestController
@RequestMapping("/items")
@Slf4j
@Api(tags = "商品模块的控制层")
public class ItemsController {
    @Autowired
    private ItemsService itemsService;

    @GetMapping("/findOne/{id}")
    @ApiOperation("查询商品详情")
    public Items  findOne(@PathVariable("id") Integer id){
        return itemsService.findOne(id);
    }

    @PutMapping("/updateOne")
    @ApiOperation("更新商品数据")
    public Items updateOne(@RequestBody Items items){
        return itemsService.updateOne(items);
    }
    @DeleteMapping("/deleteOne/{id}")
    @ApiOperation("删除商品数据")
    public boolean  deleteOne(@PathVariable("id") Integer id){
        return itemsService.deleteOne(id);
    }
    @GetMapping("/findByQueryName")
    @ApiOperation("根据名称查询商品信息")
    public Items findByQueryName(String name){
        return itemsService.findByQueryName(name);
    }
}
